package com.edu.controller.front.order;

import com.edu.service.ordertab.OrderService;
import com.edu.service.ordertab.OrderServiceImpl;
import com.edu.utils.ParamFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author ZCN
 * @version 1.0
 * @date 2021/11/25 16:30
 */
@WebServlet("/front/cancelorder")
public class CancelOrderServlet extends HttpServlet {
    private OrderService orderService = new OrderServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            ParamFormat.format(req, resp);
            Integer id = Integer.valueOf(req.getParameter("id"));
            orderService.cancelOrder(id);
            resp.sendRedirect("/front/querymyorder");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
